This survey aims to update
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.
## ── Attaching packages ───────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## Parsed with column specification:
## cols(
## .default = col_double(),
## introelapse = col_character(),
## IP = col_character()
## )
## See spec(...) for full column specifications.
# plots by gender
colors = c('female' = 'darkred',
'male' = 'darkblue',
'other' = 'darkgreen',
'unspecified' = 'darkgray')
# scatterplot of z-scored masculine/feminine scales
dat %>% ggplot(aes(x=masculine.z, y=feminine.z, color=gender))+
geom_hline(yintercept = 0)+
geom_vline(xintercept = 0)+
geom_point(size=0.1, alpha=0.1)+
scale_color_manual(values = colors)+
coord_cartesian(xlim = c(-3,3), ylim=c(-3,3))+
theme_minimal()
# stacked gender histograms for m-f: no bimodality -- just a continuum
dat %>% ggplot(aes(x=m.minus.f, fill=gender))+
# geom_density(position='identity', alpha=0.5)+
geom_histogram(position='stack', bins=100, alpha=0.5, size=1)+
scale_color_manual(values = colors)+
scale_fill_manual(values = colors)+
theme_minimal()
# gender histograms for m-f: male/female are predictably different. other is in the middle. males more variable.
dat %>% ggplot(aes(x=m.minus.f, fill=gender))+
# geom_density(position='identity', alpha=0.5)+
geom_histogram(position='identity', bins=100, alpha=0.5, size=1)+
scale_color_manual(values = colors)+
scale_fill_manual(values = colors)+
theme_minimal()
# gender densities for m-f: male/female are predictably different. other is in the middle. males more variable.
dat %>% ggplot(aes(x=m.minus.f, color=gender))+
# geom_density(position='identity', alpha=0.5)+
geom_line(stat='density', alpha=1, size=1.5)+
scale_color_manual(values = colors)+
scale_fill_manual(values = colors)+
theme_minimal()
# histogram of off-diagonal
dat %>% ggplot(aes(x=m.plus.f, fill=gender))+
geom_histogram(position='identity', bins=100, alpha=0.5, size=1)+
scale_color_manual(values = colors)+
scale_fill_manual(values = colors)+
theme_minimal()
# density of m+f: all groups appear to be equally on the continuum (no group systematically deviates more or less from the m-f line)
dat %>% ggplot(aes(x=m.plus.f, color=gender))+
# geom_density(position='identity', alpha=0.5)+
geom_line(stat='density', alpha=1, size=1.5)+
scale_color_manual(values = colors)+
scale_fill_manual(values = colors)+
theme_minimal()
# plots by sexual orientation
colors.orientation = c('heterosexual' = 'darkblue',
'homosexual' = 'darkred',
'asexual' = 'chocolate4',
'bisexual' = 'darkgreen',
'other' = 'gray',
'unspecified' = 'gray')
# gender consistency density for male/females of various sexual orientations. hetero>homo, much more so for males.
dat %>% filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified'))) %>%
ggplot(aes(x=g.consistent, color=orientation))+
facet_grid(gender~.) +
# geom_density(position='identity', alpha=1, size=1.5)+
geom_line(stat='density', alpha=1, size=1.5)+
# geom_histogram(position='identity', bins=100, alpha=0.5, size=1)+
scale_color_manual(values = colors.orientation)+
scale_fill_manual(values = colors.orientation)+
theme_minimal()
# education?
# is it just proxy for age? yes, yes it is.
dat %>% ggplot(aes(x=age, fill=education))+
geom_histogram(position='identity', bins=30, alpha=0.5, size=1)+
theme_minimal()
# gender consistency by age, orientation, gender
dat %>% filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified', 'asexual'))) %>%
ggplot(aes(x = age, y=g.consistent, color=orientation))+
facet_grid(gender~.) +
geom_point(size=0.1, alpha=0.1)+
geom_smooth(method='lm')+
scale_color_manual(values = colors.orientation)+
scale_fill_manual(values = colors.orientation)+
theme_minimal()
## `geom_smooth()` using formula 'y ~ x'
# age by orientation
dat %>% filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified'))) %>%
ggplot(aes(x=age, color=orientation))+
facet_grid(gender~.) +
# geom_density(position='identity', alpha=1, size=1.5)+
geom_line(stat='density', alpha=1, size=1)+
# geom_histogram(position='identity', bins=100, alpha=0.5, size=1)+
scale_color_manual(values = colors.orientation)+
scale_fill_manual(values = colors.orientation)+
theme_minimal()
age.qs = unname(quantile(dat$age, seq(0.1, 0.9, 0.1)))
age.cuts = c(12, age.qs, 99)
dat %>% mutate(age.bin = cut(age,
breaks = age.cuts,
labels = paste0(age.cuts[-length(age.cuts)], '-', age.cuts[-1]))) %>%
filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified', 'asexual'))) %>%
ggplot(aes(x=age.bin, fill=orientation))+
facet_grid(gender~.)+
geom_bar(position='fill')+
scale_fill_manual(values = colors.orientation)+
theme_minimal()
# which parts of gender continuum go to who?
colors.g.o = c('female-heterosexual' = 'darkred',
'female-homosexual' = 'red',
'female-bisexual' = 'pink',
'male-bisexual' = 'skyblue',
'male-homosexual' = 'blue',
'male-heterosexual' = 'darkblue')
qs= seq(0, 1, 0.02)
mf.qs = unname(quantile(dat$m.minus.f, qs))
mf.qs[1] = -Inf
mf.qs[length(mf.qs)] = Inf
mf.cuts = mf.qs
dat %>%
filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified', 'asexual'))) %>%
mutate(g.o = factor(paste0(gender, '-', orientation), levels=names(colors.g.o)),
mf.ventile = cut(m.minus.f,
mf.cuts,
labels=paste0(qs[-length(qs)], '-', qs[-1]))) %>%
ggplot(aes(x=mf.ventile, fill=g.o))+
geom_bar(position='fill')+
scale_fill_manual(values=colors.g.o)+
theme_minimal()+
theme(axis.text.x = element_text(angle = 90))
dat %>%
filter(gender %in% c('male', 'female'),
!(orientation %in% c('other', 'unspecified', 'asexual'))) %>%
mutate(orientation = factor(orientation, levels=c('homosexual', 'bisexual', 'heterosexual')),
mf.ventile = cut(m.minus.f,
mf.cuts,
labels=paste0(qs[-length(qs)], '-', qs[-1]))) %>%
ggplot(aes(x=mf.ventile, fill=orientation))+
geom_bar(position='fill')+
scale_fill_manual(values=colors.orientation)+
theme_minimal()+
theme(axis.text.x = element_text(angle = 90))